{extend name="layout" /}


{block name="title"}我的任务{/block}

{block name="body"}
<span id="userId" hidden>{$userId}</span>
<a href="{:url('logout')}" class="layui-btn layui-btn-danger">退出登录</a>
<a href="{:url('index')}" class="layui-btn">任务首页</a>
<div style="width: 85%">
    <table id="task" lay-filter="demo" style="width: 50%"></table>
</div>

<script>
    layui.use('table', function(){
        const table = layui.table;
        let url = "{:url('reviewTask')}";
        let userId = $('#userId').text();
        table.render({
            elem: '#task'
            ,height: 450
            ,url: '/api/selfApi/getMyTask?userId='+userId //数据接口
            ,page: true //开启分页
            ,cellMinWidth: 120
            ,text: {
                none: '暂无领取任务'
            }
            ,cols: [[ //表头
                {field: 'task_name', title: '任务名', width:150, sort: true, fixed: 'left'}
                ,{field: 'task_lv', title: '任务等级', width:100}
                ,{field: 'task_profit', title: '任务收益', width:150, sort: true}
                ,{field: 'task_type', title: '任务类型', width:152}
                ,{field: 'task_description', title: '任务描述', width: 250}
                ,{field: 'task_status', title: '任务状态', width: 100, templet: function (d) {
                    if(d.task_status === 1) {
                        return '<span style="color: #FF5722">未完成</span>';
                    }else if(d.task_status === 2){
                        return '<span style="color: #2D93CA">待审核</span>';
                    }else {
                        return '<span style="color: #339911">已完成</span>';
                    }
                    }}
                ,{align: 'center', title: '操作', width: 178, templet: function (d) {
                        if(d.task_status === 1) {
                            return '<a href="'+ url +'?taskId='+d.id+'&userId='+d.user_id+'"  class="layui-btn layui-btn-sm" target="_self" " ">提交审核</a>';
                        }else if(d.task_status === 2){
                            return '<span  class="" target="_self">待审核' + '</span>';
                        }else {
                            return '<span  class="" target="_self">已获取收益'+d.task_profit+'</span>';
                        }

                    }
                }
            ]],

        });

    });
</script>

{/block}